//
//  OEnterApp.m
//  soccer
//
//  Created by 上官千城 on 15/9/18.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "OEnterApp.h"
#import "UIUtils.h"

@implementation OEnterApp

/*
-(instancetype) initWithCallBack:(SEL)callBack
{
    return [super initWithName:@"OEnterApp" callBack:callBack];
}*/

-(instancetype) initWithCallBack:(SEL)callBack for:(NSObject *)recvObjc
{
    return [super initWithName:@"OEnterApp" recvObjc:recvObjc callBack:callBack];
}



-(void)request
{
    NSDictionary* params = @{
        @"token":self.token,
        @"sign":self.sign
    };
    [self send:params];
}

-(void) run:(NSData *)data erc:(NSInteger)erc
{
    //TODO:
    if (erc != SUCC) {
        //TODO:fail logic process;
        NSString *str = [NSString stringWithFormat:@"登录失败erc= %ld",erc];

        [UIUtils showAlert:@"提示" message:str left:@"退出" right:nil delegate:nil];
        return;
    }
    
    NSLog(@"enterApp logic process");
    NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    self.userId = [[dic objectForKey:@"userId"] integerValue];
    self.sex = [[dic objectForKey:@"sex"] boolValue];
    self.nickName = [dic objectForKey:@"nickName"];
    self.region = [[dic objectForKey:@"region"] integerValue];
    self.sign = [dic objectForKey:@"signature"];
    self.icon = [dic objectForKey:@"icon"];
    NSLog(@"enterApp data=%@",dic);
    
    [self mu];
}

@end
